package com.hxk.juc.thread.single;

/**
 * 静态内部类式单例模式（性能最好）
 */
public class SingleCase2 {
    private SingleCase2(){
        System.out.println(Thread.currentThread().getName()+"\t 我是SingleCase2的私有构造方法");
    }
    private static class SingleCase2Inner{
        private static SingleCase2 instance = new SingleCase2();
    }

    public static SingleCase2 getInstance(){
        return SingleCase2Inner.instance;
    }

    public static void main(String[] args) {
        for (int i = 1; i <= 10; i++) {
            new Thread(()->{
                SingleCase2.getInstance();
            },String.valueOf(i)).start();
        }
    }
}
